package www.rlicker.service.impl;

import www.rlicker.model.GroupResource;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import www.rlicker.dao.IGroupResourceDao;
import org.springframework.stereotype.Service;
import www.rlicker.mybatis.Criteria;
import www.rlicker.service.IGroupResourceService;
import com.github.pagehelper.PageHelper;
import www.rlicker.utils.TranslateToMap;
import java.util.List;

/**
 * 
 * GroupResource数据库操作接口类
 * 
 **/

@Service
public class GroupResourceServiceImpl implements IGroupResourceService{


	/**
	 * 
	 * 分页查询
	 * 
	 **/
	public List<Map<String, Object>>  queryPage (Criteria<GroupResource> param){
		PageHelper.startPage(param.getStartIndex(), param.getPageSize());
		List<GroupResource> list = groupResourceRepository.queryPage(param);
			List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,GroupResource.class);
	return map;  }

	/**
	 * 
	 * 分页总数查询
	 * 
	 **/
	public Integer queryPageCount (Criteria<GroupResource> param){
		return (Integer) groupResourceRepository.queryPageCount(param);
	}

	/**
	 * 
	 * 查询（根据主键ID查询）
	 * 
	 **/
	public GroupResource  queryEntity (Integer id ){
		return groupResourceRepository.queryEntity(id);
	}

	/**
	 * 
	 * 删除（根据主键ID删除）
	 * 
	 **/
	public String deleteById (Integer id ){
		int result = groupResourceRepository.deleteById(id);
			if ( result != 1) {
					return null;
			}
			return null;
	}

	/**
	 * 
	 * 添加 （匹配有值的字段）
	 * 
	 **/
	public String insert(GroupResource record ){
		int result = groupResourceRepository.insert(record);
			if ( result != 1) { 
					return null;
			}
			return null;
	}

	/**
	 * 
	 * 修改（匹配有值的字段）
	 * 
	 **/
	public String update (Criteria<GroupResource> param){
		int result = groupResourceRepository.update(param);
			if ( result != 1) { 
					return null;
			}
			return null;
	}
	
	@Override
	public List<GroupResource> queryPageList(Criteria<GroupResource> param) {
		return groupResourceRepository.queryPage(param);
	}

	@Autowired
	private IGroupResourceDao groupResourceRepository;

}